<template>
	<view class="content">


		<view class="top">

			<view class="son">
				<view>{{companyName}}</view>
				<!-- <img  class="qj" src="@/static/ic_arrow_smallgrey.png" alt=""> -->
			</view>

		</view>

		<u-toast ref="uToast" />

		<!-- 		<view class="gird">
			<u-grid :border="true" col="3" @click="click">
				<u-grid-item v-for="(listItem,listIndex) in list" :key="listIndex" :url="listItem.url">
					<u-icon :customStyle="{paddingTop:60+'rpx'}" :name="listItem.name" :size="80"></u-icon>
					<text class="grid-text">{{listItem.title}}</text>
				</u-grid-item>
			</u-grid>
		
		</view> -->


		<view class="list">

			<view class="meun" v-for="(listItem,listIndex) in list" :key="listIndex">
				<view class="meunlist">
					<view class="item" @click="click(listIndex)">
						<view class="">
							<u-icon :name="listItem.name" :size="113"></u-icon>
							<view class="" style="text-align: center;">
								{{listItem.title}}
							</view>

						</view>

					</view>
				</view>



			</view>

		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				userType: '999',
				companyName: "",
				title: 'Hello',
				text1: '我是公告',
				list: [],
			}
		},
		onShow() {

			this.companyName = this.$store.state.myCompanyName
			this.getPermissionList()


		},


		methods: {
			scanCode() {
				var that = this
				// 允许从相机和相册扫码
				uni.scanCode({
					scanType: ["qrCode"],
					success: (res) => {
						console.log(res);
						if (res.result) {
							const val = res.result;
							uni.navigateTo({
								url: "/pages/work/work?taskId=" + res.result
							})

						} else {

							console.log('请重新扫描');
							that.$refs.uToast.show({
								type: 'error',
								icon: false,
								title: '提示',
								message: "请重新扫描",
								iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
							})
							return false;
						}
					},
					fail: (res) => {
						that.$refs.uToast.show({
							type: 'error',
							icon: false,
							title: '提示',
							message: "未识别到二维码",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
						})
						console.log('未识别到二维码');
					}
				})
			},
			getPermissionList() {





				var that = this
				this.api.get("/User/isExistUserByOpenId/" + this.$store.state.openId, {}).then(res => {
					console.log(res)
					that.userType = res.data.userType
					that.$store.state.userType=res.data.userType
				    that.$store.commit("getUserInfo")
					

					// 如果当前登录的是自己的公司 则为超级管理员 否者判断 是否为管理员 再则为普通员工 '1'普通员工 '2'管理员
					if (that.$store.state.userId == that.$store.state.ownCompanyUserId) {
						that.list = [{
								name: 'grid',
								title: '扫菲上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '手工上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '我的计件',
								url: "/pages/mymoney/mymoney"
							},
							{
								name: 'grid',
								title: '款式管理',
								url: "/pages/clothes/clothes"
							},
							{
								name: 'grid',
								title: '客户管理',
								url: "/pages/custmoers/custmoers"
							},

							{
								name: 'grid',
								title: '员工管理',
								url: "/pages/employee/employee"
							},
							{
								name: 'grid',
								title: '计件管理',
								url: "/pages/money/money"
							}
						]
						return
					}

					if (that.userType == '1') {
						that.list = [{
								name: 'grid',
								title: '扫菲上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '手工上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '我的计件',
								url: "/pages/mymoney/mymoney"
							}
						]
					}
					if (that.userType == '2') {
						that.list = [{
								name: 'grid',
								title: '扫菲上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '手工上数',
								url: "/pages/artificial/artificial"
							},
							{
								name: 'grid',
								title: '我的计件',
								url: "/pages/mymoney/mymoney"
							},
							{
								name: 'grid',
								title: '款式管理',
								url: "/pages/clothes/clothes"
							}
						]
					}



				})




			},
			click(index) {
				if (index == 0) {

					this.scanCode()
					return
				}
				console.log(index)
				uni.navigateTo({
					url: this.list[index].url
				})

			}
		}
	}
</script>

<style>
	.meunlist {
		float: left;

	}

	.item {
		margin: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #FFFFFF;
		border-radius: 15rpx;
	}

	.list {
		width: 100%;
	}

	.meun {
		width: 100%;
	}

	.gird {
		width: 100%;
	}

	.top {
		height: 40px;
		/* 	border-top: #BBBCC6 1px solid;
		border-bottom:#BBBCC6 1px solid; */
	}

	.son {
		padding: 10px;
		font: 700;
		font-size: large;
		display: flex;
	}

	.qj {

		height: 22px;
		width: 22px;
	}

	/* .content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	} */
</style>
